home *** CD-ROM | disk | FTP | other *** search
- /*
- ** ReadSector.c - read a sector using GVP's SCSI device driver
- ** Copyright (C) 1990 by Ralph Babel, Falkenweg 3, D-6204 Taunusstein, FRG
- ** all rights reserved - alle Rechte vorbehalten
- **
- ** 03-Jun-1990 created
- */
-
- /*** included files ***/
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <devices/trackdisk.h>
- #include <libraries/dos.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <string.h>
-
- /*** external symbol references ***/
-
- void sprintf(char *, const char *, ...);
- void fprintf(BPTR, const char *, ...);
-
- /*** constants ***/
-
- #define BOARD 0 /* controller board */
- #define TID 0 /* SCSI target ID */
- #define LUN 0 /* logical unit */
-
- #define UNIT (BOARD * 100 + LUN * 10 + TID)
-
- /*** entry point (RXStartUp.obj) ***/
-
- void __stdargs __saveds main(
- ULONG argc,
- const char *const argv[])
- {
- BPTR fh;
- char *s;
- UBYTE *p;
- UBYTE *data;
- struct MsgPort *mp;
- struct IOStdReq *io;
- UWORD i, j;
- UBYTE d;
- char buffer[80];
-
- if(argc != 0) /* CLI only! */
- {
- fh = Output();
-
- if((data = AllocMem(TD_SECTOR, MEMF_CHIP)) != NULL)
- {
- if((mp = CreatePort(NULL, 0)) != NULL)
- {
- if((io = CreateStdIO(mp)) != NULL)
- {
- if(OpenDevice("gvpscsi.device", UNIT, (struct IORequest *)io, 0) == 0)
- {
- io->io_Command = CMD_READ;
- io->io_Length = TD_SECTOR;
- io->io_Data = (APTR)data;
- io->io_Offset = 0 * TD_SECTOR; /* sector offset */
-
- (void)DoIO((struct IORequest *)io);
-
- fprintf(fh, "io_Error = %d\n", io->io_Error);
-
- if(io->io_Error == 0)
- {
- fprintf(fh, "\n");
-
- buffer[70] = '\0';
-
- for(p = data, i = 0; i < TD_SECTOR; i += 16)
- {
- sprintf(buffer, "%03x:", i);
- (void)memset(buffer + 4, ' ', 66);
-
- for(s = buffer + 4, j = 0; j < 16; s += 3, ++j)
- {
- sprintf(s, " %02x", d = *p++);
- buffer[53 + j] = d >= 32 && d <= 126 || d >= 160? d: '.';
- }
-
- *s = ' ';
- fprintf(fh, "%s\n", buffer);
- }
- }
-
- /* make ALWAYS sure the motor is turned off! */
-
- io->io_Command = TD_MOTOR;
- io->io_Length = 0;
- (void)DoIO((struct IORequest *)io);
-
- CloseDevice((struct IORequest *)io);
- }
- else
- fprintf(fh, "Error %d while opening SCSI unit %ld.\n",
- io->io_Error, (long)UNIT);
-
- DeleteStdIO(io);
- }
- else
- fprintf(fh, "Could not create I/O request.\n");
-
- DeletePort(mp);
- }
- else
- fprintf(fh, "Could not create message port.\n");
-
- FreeMem(data, TD_SECTOR);
- }
- else
- fprintf(fh, "Insufficient free store.\n");
- }
- }
-